#!/bin/bash
if [ -f $1 ]
then
	if [ -z $2 ]
	then
		echo "`date '+%Y-%m-%d %H:%M:%S'` - Visits Ranking Statistics Situation : " >> VisitsRankingStatistics.log
		cat $1 | awk '{print $1}' | sort |uniq -c | sort -rn >> VisitsRankingStatistics.log
	else
		echo "`date '+%Y-%m-%d %H:%M:%S'` - Visits Ranking Statistics Situation : " >> VisitsRankingStatistics.log
		cat $1 | awk '{print $1}' | sort |uniq -c | sort -rn |head -$2 >> VisitsRankingStatistics.log
	fi
fi
echo "`date '+%Y-%m-%d %H:%M:%S'` - Error: Log File Path NOT Air" >> VisitsRankingStatistics.log
